<?php $this->load->view('tourism/layout/header') ?>
<?php js('skins/tourism','user') ?>
<header class="am-search details">
    <ul class="am-cf">
        <li class="r-black">
            <a href="javascript:history.go(-1);">
                <i class="iconfont icon-zuojiantou"></i>
            </a>
        </li>
        <li class="header-input">
            <p>评价</p>
        </li>
        <li class="header-home">
           <?php $this->load->view('tourism/layout/nav'); ?>
        </li>
    </ul>
</header>
<div class="evaluate-first">
    <form class="am-form" id="order-evaluate-submit" action="<?php echo site_url('tourism/tourismevaluate/evaluatePost')?>" method="post">
        <div class="evaluate">
        <input type="hidden" name="order_id" value="<?php echo $orderInfo->order_id;?>" >
            <?php foreach($orderProduct as $value): ?>
            <input type="hidden" name="goods_attr_id[]" value="<?php echo $value->goods_attr_id?>">
                <div class="evaluate-also am-cf">
                <div class="also-img">
                    <img class="lazy" src="/skins/tourism/images/load.jpg" data-original="<?php echo $this->config->show_image_url($value->goods_image, '300-300') ?>">
                </div>
                <div class="also-text">
                    <p><?php echo $value->goods_name;?></p>
                    <span>￥<?php echo $value->pay_amount;?></span>
                </div>
            </div>
            <ul class="am-cf">
                <input type="hidden" name="review_score[]" value="5">
                <li class="good active">
                    <div class="am-ate">
                        <i class="iconfont icon-xing"></i>
                        <span>好评</span>
                    </div>
                </li>
                <li class="just">
                    <div class="am-ate">
                        <i class="iconfont icon-xing"></i>
                        <span>中评</span>
                    </div>
                </li>
                <li class="bad">
                    <div class="am-ate">
                        <i class="iconfont icon-xing"></i>
                        <span>差评</span>
                    </div>
                </li>
            </ul>
            <div class="am-form-group">
                <textarea class="leave" name="user_content[]"> </textarea>
            </div>
            <?php endforeach ?>
        </div>
        <div class="mode-sure">
            <button type="submit" class="am-btn">发表评价</button>
        </div>
    </form>
</div>
<?php $this->load->view('tourism/layout/footer') ?>
<script type="text/javascript">
    //评论
    $('div.evaluate').on(status, 'ul li', function(e){
        if (!$(this).hasClass('active')) {
            $(this).siblings().removeClass('active');
            $(this).addClass('active');
        }
    });

    $('#order-evaluate-submit').submit(function(event){
        $('input[name="review_score[]"]').each(function(i){
            if ($(this).parent('ul').find('.active').hasClass('good')) {
                $(this).val(5);
            } else if($(this).parent('ul').find('.active').hasClass('just')) {
                $(this).val(3);
            } else {
                $(this).val(1);
            }
        });
        $('textarea[name="user_content[]"]').each(function(e){
            var user_content = $(this).val().length;
            if (user_content <= 1 &&  user_content <= 60) {
                alertMessage('评价内容的不能为空');
                event.preventDefault();
            }
        });

        if($('input[name=order_id]').val() < 1){
            alertMessage('找不到该产品，请刷新从试');
            window.location.reload();
            event.preventDefault();
        }

        $('submit').attr('disabled', 'disabled');
        $('submit').html('正在提交...');
    });
</script>
